#include <bits/stdc++.h>
using namespace std;
int n,r[100005],cnta,cntb;
bool flag=true;
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    unordered_map<int,int> mp;
    cin>>n;
    for (int i=1;i<=n;i++){
        cin>>r[i];
        mp[r[i]]++;
        if (r[i]==1) cnta++;
        else if (r[i]==2) cntb++;
        else flag=false;
    }
    if (flag) cout<<n-min(cnta,cntb);
    else{
        int last=0;
        for (auto i:mp){
            n-=min(i.second,last);
            if (i.second>last) last=i.second;
        }
        cout<<n;
    }
    return 0;
}
